﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace IntraVision.Web
{
    [DataContract]
    public class AJAXResult<TEntity> : AJAXResult
    {
        private List<TEntity> _Entities;

        [DataMember]
        public List<TEntity> Entities { get { return _Entities; } set { _Entities = value; } }

        public AJAXResult()
        {
            _Entities = new List<TEntity>();
        }
    }

    [DataContract]
    public class AJAXResult
    {
        private bool _IsOK;
        private string _Id;
        private string _Result;
        private string _Description;

        [DataMember]
        public bool IsOK
        {
            get { return _IsOK; }
            set { _IsOK = value; }
        }

        [DataMember]
        public string Id
        {
            get { return _Id; }
            set { _Id = value; }
        }

        [DataMember]
        public string Result
        {
            get { return _Result; }
            set { _Result = value; }
        }

        [DataMember]
        public string Description
        {
            get { return _Description; }
            set { _Description = value; }
        }

        public AJAXResult(Exception ex)
        {
            _IsOK = false;
            _Description = ex.Message;
        }

        public AJAXResult(bool isOK)
        {
            _IsOK = isOK;
        }

        public AJAXResult() :this(true) { }
    }
}
